// import Cookies from 'js-cookie'
const TOKEN_NAME = process.env.VUE_APP_TOKEN_NAME
const TOP_USER_ID = process.env.VUE_APP_TOP_USER_ID
const LAST_PATH = 'lastPath'
const FIRST_PATH = 'firstPath'
const USER_ID = 'userId'
export function setToken(token) {
    localStorage.setItem(TOKEN_NAME,token)
}

export function getToken() {
    return localStorage.getItem(TOKEN_NAME)
}

//设置推荐人
export function setTopUser(topUserId) {
    localStorage.setItem(TOP_USER_ID,topUserId)
}

export function getTopUserId() {
    let str = localStorage.getItem(TOP_USER_ID)
    // if(str instanceof Array){
    //     str = str[0]
    // }
    if(str&&str.indexOf("[")>-1){
        str = JSON.parse(str)[0]
    }
    return str
}

//设置上次URL
export function setLastPath(path) {
    localStorage.setItem(LAST_PATH,path)
}

export function getLastPath() {
    return localStorage.getItem(LAST_PATH)
}

//设置首次URL
export function setFirstPath(path) {
    localStorage.setItem(FIRST_PATH,path)
}

export function getFirstPath() {
    return localStorage.getItem(FIRST_PATH)
}

//设置用户ID
export function setUserId(userId) {
    localStorage.setItem(USER_ID,userId)
}

export function getUserId() {
    return  localStorage.getItem(USER_ID)
}


export function setTeamId(teamId){
    localStorage.setItem("TeamId", teamId)
}


export function setShareId(shareId){
    localStorage.setItem("ShareId", shareId)
}

export function getShareId(){
    return  localStorage.getItem("ShareId")
}

export function getTeamId(){
   return  localStorage.getItem("TeamId")
}